<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class Auth {
	public $ci;

	public function __construct(){
		$this->ci =& get_instance();
		$this->ci->load->library('session');
	}

	function checkLogin(){
		if(!$this->ci->session->userdata('Email')) return false;
		return true;
	}
	
	function checkAdminLogin(){
		if($this->ci->session->userdata('Email') && 
			$this->ci->session->userdata('Group_id') == '1') return true;
		return false;
	}

	function setSessionUser($data){
		$user = array();
		foreach($data as $key => $val){
			$this->ci->session->set_userdata($key, $val);
		}
	}
	
	function setSessionUserName($username){
		$this->ci->session->set_userdata('Username', $username);
	}
	
	function setSessionGroupId($group_id){
		$this->ci->session->set_userdata('Group_id', $group_id);
	}

}